home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2008 January / Cybermycha 1_2008.iso / Data.cab / _CC36B14C552B40C1ABB746FD2B52229F < prev    next >
Encoding:
Text File  |  2004-05-27  |  2.0 KB  |  100 lines

  1.  
  2. regc(2, "COMBINED_XFORM")
  3. regc(6, "MODEL_XFORM")
  4.  
  5. regc(12, "FOG_PARAMS")
  6.  
  7. regc(13, "CAMERA_POS_MS")
  8. regcn(14, "DIRECTIONAL_DIR_MS", 0)
  9.  
  10. regc(20, "TEXTURE2_XFORM")
  11. regc(24, "TEXTURE3_XFORM")
  12.  
  13. regc4f(30, 0.0, 0.0, 0.0, %sunvisibility)
  14. // ------------ c40 - c60 reserved
  15. !include("vs_spot_consts.inc")
  16.  
  17. vshader("
  18.  
  19. #define point        v0
  20. #define normal        v1
  21. #define tangent        v2
  22. #define tcoord        v3
  23.  
  24. #define fogp    c12
  25. #define cpos    c13
  26. #define ldir    c14
  27.  
  28.     vs_1_1
  29.  
  30. #include    <cardef.h>
  31. #include    <fog.inc>
  32.  
  33.     def c0, SPECULARPOW, 0, 0, 0
  34.     def    c1, 1, 0, 0, GLASSFRESNELSCALE
  35.  
  36.     dcl_position    point
  37.     dcl_normal    normal
  38.     dcl_tangent    tangent
  39.     dcl_texcoord    tcoord
  40.  
  41.     ; output position
  42.     m4x4    oPos, point, c2
  43.  
  44.     ; E in model space
  45.     add r2, cpos, -point
  46.       ; fresnel
  47.     dp3 r6.w, r2, r2
  48.     rsq r6.w, r6.w
  49.     mul r6.xyz, r2, r6.w
  50.  
  51.     dp3    r6.w, r6, normal
  52.     mad r6.w, r6.w, -r6.w, c1.x  // -dot(E, N)*dot(E, N)+1 = 1- pow(dot(E, N),2)
  53.     mul    r6.w, r6.w, r6.w        //f^2
  54.     ; output fresnel
  55.     mul oD1.w, r6.w, c1.w
  56.  
  57.     ; normalize E
  58.     dp3 r2.w, r2, r2
  59.     rsq r2.w, r2.w
  60.     mul r2.xyz, r2, r2.w
  61.  
  62.     ; reflect E
  63.     dp3 r5.w, r2, normal
  64.     add r6.w, r5.w, r5.w
  65.     mad r6.xyz, normal, r6.w, -r2 // dot(E, N)*2 *N - E
  66.  
  67.     ; output cubemap
  68.     m3x3    oT3, -r6, c6
  69.  
  70.     dp3        r4.x, normal, ldir        ; diffuse N*L
  71.     dp3        r4.y, ldir, r6        ; specular L*E
  72.     mov        r4.w, c0.x              ; specular pow
  73.     lit        r3, r4
  74.  
  75.     ; output diffuse
  76.     mov        oD0.w, r3.y   //  sun
  77.     ; output specular
  78.     mul        oD1.xyz, r3.z, c30.w    //sunvisibility
  79.  
  80. ;------------------------------------------
  81. // spot lights
  82. // used r0 - r2
  83. #if VS_SPOTLIGHTS
  84. #include <vs_spot_func.inc>
  85. #endif
  86. ;----------------------------
  87.     ; output texcoords
  88.     mov        oT0, tcoord           // color
  89.     mov     oT1, tcoord        // dirt
  90.  
  91.     ; terrain lightmap texgen (from model space)
  92.     dp4        oT2.x, point, c20
  93.     dp4        oT2.y, point, c21
  94.  
  95.     ; calc fog
  96.        dp4    r0.x, point, c4
  97.        FOG(r0.x, fogp, r10)
  98. ")
  99.  
  100.